package com.zhonghui.controller;

import com.zhonghui.common.core.result.FwResult;
import com.zhonghui.model.UserAddress;
import com.zhonghui.service.UserAddressService;
import com.zhonghui.service.UserService;
import com.zhonghui.vo.LoginVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

@RestController
@Api(value = "地址信息")
@Slf4j
@Validated
public class UserAddressController {


    @Autowired
    private UserAddressService userAddressService;


    @ApiOperation("地址查询")
    @PostMapping("/select")
    public FwResult<UserAddress> login(String userId){
        return userAddressService.select(userId);
    }


    @ApiOperation("删除地址")
    @PostMapping("/delete")
    public FwResult<UserAddress> delete(String userId){
        return userAddressService.delete(userId);
    }


    @ApiOperation("添加地址")
    @PostMapping("/insert")
    public FwResult<UserAddress> insert(UserAddress userAddress){
        return userAddressService.insert(userAddress);
    }


    @ApiOperation("修改地址")
    @PostMapping("/update")
    public FwResult<UserAddress> update(String userId){
        return userAddressService.update(userId);
    }
}
